package com.egao.oa.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.oa.mapper.ProjectUpdateMapper;
import com.egao.oa.entity.ProjectUpdate;
import com.egao.oa.service.ProjectUpdateService;
import org.springframework.stereotype.Service;
import com.egao.oa.biz.ProjectUpdateBiz;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * 项目发布服务实现类
 * @author : Doman
 * @date : 2020-08-20 13:24:00
 * @version ：1.0
 */
@Service
public class ProjectUpdateServiceImpl /*extends ServiceImpl<ProjectUpdateMapper, ProjectUpdate> */implements ProjectUpdateService {

	@Autowired
	private ProjectUpdateBiz projectUpdateBiz;

    /**
    @Override
    public PageResult<ProjectUpdate> listPage(PageParam<ProjectUpdate> page) {
        List<ProjectUpdate> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<ProjectUpdate> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, ProjectUpdate projectUpdate, User loginUser)  throws Exception{
        return projectUpdateBiz.list(page,projectUpdate,loginUser);
    }

    @Override
    public List<ProjectUpdate> list(ProjectUpdate projectUpdate, User loginUser) {
        return projectUpdateBiz.list(projectUpdate,loginUser);
    }

    @Override
    public JsonResult getById(ProjectUpdate projectUpdate) {
        return JsonResult.ok().setData(projectUpdateBiz.getById(projectUpdate));
    }

    @Transactional
    @Override
    public JsonResult save(ProjectUpdate projectUpdate, User loginUser) {
        if (projectUpdateBiz.save(projectUpdate, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(ProjectUpdate projectUpdate, User loginUser) {
        if (projectUpdateBiz.update(projectUpdate, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(ProjectUpdate projectUpdate, User loginUser) {
        if (projectUpdateBiz.remove(projectUpdate, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
